<!--
 * @Author: 孙开源 && sunkaiyuan@namenode.cn
 * @Date: 2023-09-22 10:26:19
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @LastEditTime: 2023-10-03 16:31:29
 * @Description: 
 * 
-->
<template>
  <el-dialog  draggable overflow v-model="visible" :title="'修改客户名称'" :width="400" destroy-on-close @closed="$emit('closed')">

    <sk-tabs type="border-card">
      <el-tab-pane ref="tab" label="基础信息">
        <el-form :model="form" :rules="rules" ref="dialogForm" label-width="70px">
          <el-row :gutter="40" justify="space-evenly">
            <el-col :span="18">
              <el-form-item label="简称" prop="name">
                <el-input v-model="form.name"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row :gutter="40" justify="space-evenly">
            <el-col :span="18">
              <el-form-item label="全称" prop="fullname">
                <el-input v-model="form.fullname"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </el-tab-pane>
    </sk-tabs>
    <template #footer>
      <el-button @click="visible = false">取 消</el-button>
      <el-button type="primary" :loading="isSaveing" @click="submit()">保 存</el-button>
    </template>
  </el-dialog>
</template>

<script>

export default {
  emits: ["success", "closed"],
  components: {},
  data() {
    return {
      form: {},
      rules: {
        name: { required: true, message: "请输入简称" },
        fullname: { required: true, message: "请输入全称" },
      },
      visible: false,
      isSaveing: false,
    };
  },

  mounted() { },
  methods: {
    //显示
    open() {
      this.visible = true;
      return this;
    },
    //表单提交方法
    submit() {
      this.$refs.dialogForm.validate(async (valid) => {
        if (valid) {
          this.isSaveing = true;
          var res = await this.$API.basedata.businessCompany.save.post(this.form);
          this.isSaveing = false;
          if (res.code == 200) {
            this.$emit("success", this.form, this.mode);
            this.visible = false;
            this.$message.success("操作成功");
          }
        }
      });
    },

    //表单注入数据
    setData(data) {
      this.form = data;
    },
  },
};
</script>
<style></style>
